// pages/index/thirdPage.js
const app = getApp();
const util = require("../../../../utils/util");
Page({
  data: {
    allServer: "", // 全部服务
  },
  onLoad: function (options) {
    let id = options.id;
    ks.setNavigationBarTitle({
      title: decodeURIComponent(options.title),
    });
    util.getUrl(app.globalData.url_new).then(res => {
      let $thirdPageServer = {
        ac: "allServer",
        flag: "getServer",
        type: app.globalData.platform,
        city: "sz",
        id,
      };
      util.bstrequest('index.php', $thirdPageServer, "post").then(res => {
        let allServer = JSON.parse(JSON.stringify(res.data.allServer));
        this.setData({
          allServer
        });
      });
    });
  },
  fiveBindTap(e) {
    // 五级类目
    let index = e.currentTarget.dataset.index;
    let data = this.data.allServer[index];
    if (data.ser_link_method != '0') {
      util.click2NextProgram(data);
      util.clickNumber(data.id);
    }
  },
  sixBindTap(e) {
    let index1 = e.currentTarget.dataset.index1;
    let index2 = e.currentTarget.dataset.index2;
    let data = this.data.allServer[index1].child[index2];
    // 办事日历
    if (data.id === "2997") {
      ks.navigateTo({
        url: '/pages/tools/calendar/index/index',
      });
      util.clickNumber(data.id, 2);
      return;
    }
    // 网点查询
    if (data.id === '3017') {
      ks.navigateTo({
        url: `/pages/tools/wangdian/index/index`,
      });
      util.clickNumber(data.id, 2);
      return;
    }
    // 社保测算
    if (data.id === '3027') {
      ks.navigateTo({
        url: `/pages/tools/shebao/index/index`,
      });
      util.clickNumber(data.id, 2);
      return;
    }
    // 名单查询
    if (data.id === '3007') {
      ks.navigateTo({
        url: '/pages/tools/listQuery/index/index',
      });
      util.clickNumber(data.id, 2);
      return;
    }
    // 公积金计算器
    if (data.id === "3053") {
      ks.navigateTo({
        url: '/pages/tools/loan/index/index',
      });
      util.clickNumber(data.id, 2);
      return;
    } 
    if (data.ser_link_method != '0') {
      util.click2NextProgram(data);
      util.clickNumber(data.id);
      return;
    }
  },
  onShareAppMessage() {
    return {
      imageUrl: "http://imgbdb3.bendibao.com/xcxbdb/file/20212/9/20210209161843_68677.jpg"
    }
  }
});